package threadspace.data;

import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

/**
 * A single course offered by the institution
 * 
 * @author Robert
 *
 */
@PersistenceCapable
public class Course {
	/** the two character department code (like CS) **/
	@Persistent
	private String department;
	/** the actual number of the course (like 4911) **/
	@Persistent
	private String number;
	/** a description of the course **/
	@Persistent
	private String description;
	/** the number of credit hours in the course **/
	@Persistent
	private int hours;
	/** the prerequisites for this course */
	@Persistent
	private List<Course> prerequisites;
	/** internal key used by JDO, automagically assigned */
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private int key;

	/**
	 * Construct a new course
	 * @param dept the department
	 * @param num the number
	 * @param desc the description
	 * @param hrs the credit hours
	 */
	public Course(String dept, String num, String desc, int hrs) {
		department = dept;
		number = num;
		description = desc;
		hours = hrs;
		prerequisites = new ArrayList<Course>();
	}
	
	/**
	 * Add a prereq to a course
	 * @param c the prereq to add
	 */
	public void addPrequisite(Course c) {
	   prerequisites.add(c);
	}
	
	/*********************************************************/
    /*****************Accessors*******************************/
	public List<Course> getPrerequisites() {
		return prerequisites;
	}
	public String getDepartment() {
		return department;
	}
	public void setDepartment(String department) {
		this.department = department;
	}
	public String getNumber() {
		return number;
	}
	public void setNumber(String number) {
		this.number = number;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public int getHours() {
		return hours;
	}
	public void setHours(int hours) {
		this.hours = hours;
	}
	public int getKey() {
		return key;
	}
	public void setKey(int key) {
		this.key = key;
	}

}
